package com.dgut.staffmodule.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.dgut.common.util.Gender;
import com.fasterxml.jackson.annotation.JsonFormat;

@Entity
@Table(name = "t_staff")
public class Staff {
	private Long id;// 员工Id
	private String staffName;// 姓名
	private String password;// 密码
	private Gender sex;// 性别
	private int age;// 年龄
	private String phone;// 手机号
	@DateTimeFormat(pattern = "yyyy/MM/dd")
	private Date birthday;// 出生日期
	private String address;// 地址
	private String education;// 学历
	@DateTimeFormat(pattern = "yyyy/MM/dd")
	private Date inTime;// 入职时间
	private String hobby;// 爱好

	private Department department;// 员工与部门的关系是多对一
	private String position;// 职位

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	@Column(nullable = false, unique = true)
	public String getStaffName() {
		return staffName;
	}

	@Column(nullable = false)
	public String getPassword() {
		return password;
	}

	// @Enumerated(EnumType.STRING)
	@Column(nullable = false)
	public Gender getSex() {
		return sex;
	}

	@Column(nullable = false)
	public int getAge() {
		return age;
	}

	@Column(nullable = false, length = 11)
	public String getPhone() {
		return phone;
	}

	@JsonFormat(pattern = "yyyy/MM/dd", timezone = "GMT+8")
	public Date getBirthday() {
		return birthday;
	}

	public String getAddress() {
		return address;
	}

	@Column(nullable = false)
	public String getEducation() {
		return education;
	}

	@JsonFormat(pattern = "yyyy/MM/dd", timezone = "GMT+8")
	public Date getInTime() {
		return inTime;
	}

	public String getHobby() {
		return hobby;
	}

	// 员工与部门的关系为n:1
	// @JsonIgnore
	@ManyToOne(cascade = CascadeType.ALL) //
	public Department getDepartment() {
		return department;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setStaffName(String staffName) {
		this.staffName = staffName;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setSex(Gender sex) {
		this.sex = sex;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public void setEducation(String education) {
		this.education = education;
	}

	public void setInTime(Date inTime) {
		this.inTime = inTime;
	}

	public void setHobby(String hobby) {
		this.hobby = hobby;
	}

	@Override
	public String toString() {
		return "Staff [id=" + id + ", staffName=" + staffName + ", password=" + password + ", sex=" + sex + ", age="
				+ age + ", phone=" + phone + ", birthday=" + birthday + ", address=" + address + ", education="
				+ education + ", inTime=" + inTime + ", hobby=" + hobby + "]";
	}

}
